import os
from configuration.models import Setting

def default_path():
  t, c = Setting.objects.get_or_create(key='ASSETS_EXPORT_DIR', defaults={'value': '/tmp/'})
  if c: t.save()
  if not os.path.exists(t.value):
    path = os.environ.get("TEMP")
    if not path:
      if os.name == 'nt':
        path = "c:/tmp/"
      else:
        path = "/tmp/"
    t.value = path
    t.save()
  else:
    path = t.value
  if not path.endswith(os.sep):
    path += os.sep
  return path
  
def blender_path():
  t, c = Setting.objects.get_or_create(key='BLENDER', defaults={'value': 'blender'})
  if c: t.save()
  return t.value
  
def b2cs_path():
  t, c = Setting.objects.get_or_create(key='B2_5CS', defaults={'value': 'b2.5cs/scripts/io/'})
  if c: t.save()
  return t.value

def fs_path():
  t, c = Setting.objects.get_or_create(key='DAMNFileSystem', defaults={'value': '/tmp/fs'})
  if c: t.save()
  return t.value
